package com.icinfo.cloud.provider.punish.ucase.investigateevidence.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * 描述：案件操作类型
 *
 * @author shishengyao
 * @description
 * @date 2022/5/19
 */
@AllArgsConstructor
public enum CaseStatusChangeTypeEnum {
    /**
     * 案件操作类型
     */
    POSTPONE("POSTPONE", "案件延期","CQYQSQB"),
    SUSPEND("SUSPEND", "案件中止","CQZZQZZXSQB"),
    TERMINATE("TERMINATE", "案件终止","ZZSQB"),
    REVOKE("REVOKE", "立案撤销","CXLASQB"),
    RENEW("SUSPEND_RENEW", "案件恢复","");


    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;
    /**
     * 文件类型代码
     */
    @Getter
    private String documentKindCode;

    /**
     * 根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (CaseStatusChangeTypeEnum e : CaseStatusChangeTypeEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return null;
    }


    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author XiangYuYu
     * @date 2021/09/15
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (CaseStatusChangeTypeEnum e : CaseStatusChangeTypeEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public static CaseStatusChangeTypeEnum getEnumByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (CaseStatusChangeTypeEnum e : CaseStatusChangeTypeEnum.values()) {
            if (code.equals(e.getCode())) {
                return e;
            }
        }
        return null;
    }

    /**
     * 根据文书种类code 获取枚举
     *
     * @param documentKindCode 文件类型代码
     * @return {@link CaseStatusChangeTypeEnum }
     * @author shishengyao
     * @date 2022/05/25
     */
    public static CaseStatusChangeTypeEnum getEnumByDocumentKindCode(String documentKindCode) {
        if (ObjectUtils.isEmpty(documentKindCode)) {
            return null;
        }
        for (CaseStatusChangeTypeEnum e : CaseStatusChangeTypeEnum.values()) {
            if (documentKindCode.equals(e.getDocumentKindCode())) {
                return e;
            }
        }
        return null;
    }

    /**
     * 描述：校验文书是否是案件操作文书
     *
     * @param documentKindCode 文件类型代码
     * @return boolean
     * @author shishengyao
     * @date 2022/05/25
     */
    public static boolean isCaseChangeDocEnum(String documentKindCode) {
        boolean flag = false;
        if (StringUtils.isEmpty(documentKindCode)){
            return false;
        }
        for (CaseStatusChangeTypeEnum e : CaseStatusChangeTypeEnum.values()) {
            if (e.getDocumentKindCode().equalsIgnoreCase(documentKindCode)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
